package org.doubango.FrCall.Screens;

import java.util.ArrayList;
import java.util.HashMap;

import org.doubango.FrCall.Engine;
import org.doubango.FrCall.R;
import org.doubango.FrCall.Services.IScreenService;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class ScreenSearchFriendNearbyResult extends BaseScreen {

	private static String TAG = ScreenChatSip.class.getCanonicalName();
	private final IScreenService mScreenService;
	
	private Button backToSearchFriendNearbyViewFromShowSearchedFriendNearbyResultView;
	private ListView searchFriendNearbyResultList;
	
	public ScreenSearchFriendNearbyResult() {
		super(SCREEN_TYPE.SEARCH_FRIEND_NEARBY_RESULT, TAG);
		mScreenService = ((Engine)Engine.getInstance()).getScreenService();
	}


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.screen_search_friend_nearby_result);
		searchFriendNearbyResultList = (ListView) findViewById(R.id.search_friend_nearby_result_list);
		backToSearchFriendNearbyViewFromShowSearchedFriendNearbyResultView = (Button) findViewById(R.id.back_to_search_friend_nearby_view_from_show_searched_friend_nearby_result_view);
		backToSearchFriendNearbyViewFromShowSearchedFriendNearbyResultView.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mScreenService.show(ScreenSearchFriendNearby.class);
			}
		});
		HashMap<String, String> searchFriendNearbyResultMap = new HashMap<String, String>();
		searchFriendNearbyResultMap.put("SearchFriendNearbyResultName", "胡淑玲");
		searchFriendNearbyResultMap.put("SearchFriendNearbyResultDistance", "100米内");
		ArrayList<HashMap<String, String>> searchFriendNearbyResultData = new ArrayList<HashMap<String,String>>();
		for(int i=0;i<10;i++){
			searchFriendNearbyResultData.add(searchFriendNearbyResultMap);
		}
		SimpleAdapter searchFriendNearbyResultAdapter = new SimpleAdapter(this, searchFriendNearbyResultData, R.layout.search_friend_nearby_list_item, new String[]{"SearchFriendNearbyResultName","SearchFriendNearbyResultDistance"}, new int[]{R.id.search_friend_nearby_result_name,R.id.search_friend_nearby_result_distance});
		searchFriendNearbyResultList.setAdapter(searchFriendNearbyResultAdapter);
		searchFriendNearbyResultList.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				mScreenService.show(ScreenSearchedFriendInfo.class);
			}
		});
	}
	

}
